Skip to content

Fix #20475 improve labels in Deck dialogs#20492

Closed
UdaybhanRaj-Dev wants to merge 1 commit intoankidroid:mainfrom
UdaybhanRaj-Dev:fix-deck-dialog-label-20475
Closed

Fix #20475 improve labels in Deck dialogs#20492
UdaybhanRaj-Dev wants to merge 1 commit intoankidroid:mainfrom
UdaybhanRaj-Dev:fix-deck-dialog-label-20475

Conversation

@UdaybhanRaj-Dev
Copy link

@UdaybhanRaj-Dev UdaybhanRaj-Dev commented Mar 16, 2026

Purpose / Description

This PR improves the input field labels used in the following dialogs:

  • Create Deck
  • Create Subdeck
  • Rename Deck

Previously the dialog used a generic text input field without a clear label, which could make it unclear what users should enter.
This change adds contextual hints depending on the dialog type to improve clarity and user experience.

Fixes

Fixes #20475

Approach

The dialogs use a shared reusable layout dialog_generic_text_input.xml.
Instead of creating multiple layouts, the hint for the TextInputLayout is set dynamically in CreateDeckDialog.kt depending on the DeckDialogType.

The following hints are applied:

  • Create Deck → "Deck name"
  • Create Subdeck → "Sub deck name"
  • Rename Deck → "New deck name"

New string resources added:

  • deck_name
  • sub_deck_name
  • new_deck_name

This keeps the UI layout reusable while providing clearer input labels for each dialog.

How Has This Been Tested?

Tested locally by running the app and verifying the dialogs.

Steps:

  1. Open Create Deck dialog → shows hint "Deck name"
  2. Open Create Subdeck dialog → shows hint "Sub deck name"
  3. Open Rename Deck dialog → shows hint "New deck name"

Test environment:
Tested using a physical Android device and emulator

The existing validation and dialog behavior remain unchanged.

Learning (optional, can help others)

While working on this issue, I explored how reusable dialog layouts are implemented in the project and how TextInputLayout hints can be updated dynamically depending on dialog context.

Screenshots

Create Deck Create Subdeck Rename Deck
Screenshot_20260315_222225 Screenshot_20260315_222449 Screenshot_20260315_222417

Checklist

  • You have a descriptive commit message with a short title (first line, max 50 chars).
  • You have commented your code, particularly in hard-to-understand areas
  • You have performed a self-review of your own code
  • UI changes: include screenshots of all affected screens (in particular showing any new or changed strings)
  • UI changes UI Changes: You have tested your change using the Google Accessibility Scanner
    (https://play.google.com/store/apps/details?id=com.google.android.apps.accessibility.auditor)

@github-actions
Copy link
Contributor

Important

Maintainers: This PR contains Strings changes

  1. Sync Translations before merging this PR and wait for the action to complete
  2. Review and merge the auto-generated PR in order to sync all user-submitted translations
  3. Sync Translations again and merge the PR so the huge automated string changes caused by merging this PR are by themselves and easy to review

@manocormen
Copy link
Contributor

Hi. Just a couple of suggestions:

  • You may want to shorten your commit message; the PR template checklist asks to limit it to 50 chars.
  • More generally, you may want to keep the template checklist in your PR description, and tick items off as you complete them. Most notably, it'd be good to know if/how you've tested your PR.

@UdaybhanRaj-Dev
Copy link
Author

Hi. Just a couple of suggestions:

  • You may want to shorten your commit message; the PR template checklist asks to limit it to 50 chars.
  • More generally, you may want to keep the template checklist in your PR description, and tick items off as you complete them. Most notably, it'd be good to know if/how you've tested your PR.

Thank you for the suggestions. I have shortened the commit message and updated the PR description with the checklist and testing details.

@UdaybhanRaj-Dev UdaybhanRaj-Dev force-pushed the fix-deck-dialog-label-20475 branch from 2caf48f to b4ac4fd Compare March 16, 2026 12:57
@UdaybhanRaj-Dev UdaybhanRaj-Dev changed the title Improve labels in Create Deck, Create Subdeck, and Rename Deck dialogs (#20475) Fix #20475 improve labels in Deck dialogs Mar 16, 2026
@Ayush-Patel-56
Copy link
Contributor

Hi @UdaybhanRaj-Dev, using semantic commits is a good approach. Try to use that in future PRs.

@UdaybhanRaj-Dev
Copy link
Author

UdaybhanRaj-Dev commented Mar 17, 2026

Hi @UdaybhanRaj-Dev, using semantic commits is a good approach. Try to use that in future PRs.

Thank you @Ayush-Patel-56 for the suggestion. I will follow semantic commit conventions in future PRs.

@sanjaysargam sanjaysargam self-requested a review March 17, 2026 17:17


<com.google.android.material.textfield.TextInputLayout xmlns:android="http://schemas.android.com/apk/res/android"
<com.google.android.material.textfield.TextInputLayout
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unrelated change

// we need the fully-qualified name for subdecks

val maybeDeckName = fullyQualifyDeckName(dialogText = text)
// if the name is empty, it seems distracting to show an error
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May I know why you removed this comment ?

positiveButton(positiveButtonTextRes) {
onPositiveButtonClicked()
}
positiveButton(positiveButtonTextRes) { onPositiveButtonClicked() }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unrelated change

} else {
null
}
if (text.containsNumberLargerThanNine()) context.getString(R.string.create_deck_numeric_hint) else null
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unrelated change

.Builder(context)
.show {
title(title)
// Resource ID for the dialog's positive action button text.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

copy/paste: May I know why you removed this comment ?

// --- Dynamic Hint for 3 different dialogs ---
val inputLayout = dialog.getInputTextLayout()
when (deckDialogType) {
DeckDialogType.DECK -> inputLayout.hint = context.getString(R.string.deck_name)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the hint is set inside the .input { } callback, which runs on text updates
Was this intentionally done per-keystroke, or can we set the hint once when the dialog is created ?


<string name="deck_name">Deck name</string>
<string name="sub_deck_name">Subdeck name</string>
<string name="new_deck_name">New Deck name</string>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks inconsistent with sentence case

DeckDialogType.RENAME_DECK -> inputLayout.hint = context.getString(R.string.new_deck_name)
DeckDialogType.FILTERED_DECK -> inputLayout.hint = context.getString(R.string.deck_name)
}
// --- End Dynamic Hint ---
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this

}.input(prefill = initialDeckName, displayKeyboard = true, waitForPositiveButton = false) { dialog, text ->

// defining the action of done button in ImeKeyBoard and enter button in physical keyBoard
// --- Dynamic Hint for 3 different dialogs ---
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this
instead explain in comment properly

@sanjaysargam sanjaysargam added Needs Author Reply Waiting for a reply from the original author and removed Needs Review labels Mar 18, 2026
@ZornHadNoChoice
Copy link
Collaborator

Hi. I think it's better if you changed the strings:

  • From "Deck name" to "Name".
  • From "Subdeck name" to "Name".
  • From "New Deck name" to "New name".
  • From "Deck already exists" to "Name already used".

The reason is to unify this and similar dialogs, shorten the text, and because the titles already convey the action required.

@UdaybhanRaj-Dev
Copy link
Author

Hi @sanjaysargam ,

Thank you for the detailed review.

I understand that I introduced some unnecessary changes beyond the scope of the issue. I will clean up the PR by removing unrelated changes, extra comments, and simplifying the implementation.

I will also move or remove logic that does not need to run on every input update and ensure the code follows existing patterns.

I’ll update the PR shortly. Thanks again for your feedback!

@UdaybhanRaj-Dev
Copy link
Author

Hi @ZornHadNoChoice,

Thank you for the suggestion. That makes sense — using shorter and consistent labels improves clarity across dialogs.

I will update the strings as suggested:

  • "Name"
  • "New name"
  • "Name already used"

and align them with similar dialogs.

I’ll push the changes shortly. Thanks for the guidance!

@david-allison
Copy link
Member

Hi, closing this as-per: https://github.com/ankidroid/Anki-Android/blob/main/AI_POLICY.md#new-contributors

The replies look LLM generated, and this PR fails my "You have performed a self-review of your own code" check - there's a number of comments which seem to have been removed for no reason

@UdaybhanRaj-Dev
Copy link
Author

Hi,
Thank you for your feedback and I understand your concern. I apologize to you. I did use AI tools when drafting responses and reviewing my changes, but now I realize that I should have done better by taking more time to properly understand the code and look and understand it myself successfully. I also see that some changes were not appropriate and are my fault and I am going to update Codebase myself going forward. I understand that I will focus only on my work and make appropriate changes and will also see that whatever I have done is right and in the future Will do more careful review before submitting PR and thanks for your guidance.

@UdaybhanRaj-Dev UdaybhanRaj-Dev deleted the fix-deck-dialog-label-20475 branch March 19, 2026 12:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs Author Reply Waiting for a reply from the original author New contributor Strings

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve the "Create deck", "Create subdeck", and "Rename deck" dialogs

6 participants